package com.base.cn.platform.os.entity.exam.question;

/**
 * 试题类型枚举
 *
 * @author s.li
 * @date 2018/12/29
 */
public enum QuestionTypeEnum {
    SINGLE("单选题",1),//单选
    MULTI("多选题",2),//多选
    JUDGE("判断题",3),//判断
    BLANK("填空题",4),//填空
    SPECIAL("简答题",5),//简答
    COMPLEX("复合题",6);//复合试题

    private String templateName;
    private int type;

    QuestionTypeEnum(String templateName,int type){
        this.templateName = templateName;
        this.type = type;
    }

    public static int getType(String templateName){
        for(QuestionTypeEnum typeEnum : QuestionTypeEnum.values()){
            if(typeEnum.getTemplateName().equals(templateName.trim())){
                return typeEnum.getType();
            }
        }
        return 0;
    }

    public static QuestionTypeEnum getQuestionTypeEnum(String templateName){
        for(QuestionTypeEnum typeEnum : QuestionTypeEnum.values()){
            if(typeEnum.getTemplateName().equals(templateName)){
                return typeEnum;
            }
        }
        return null;
    }


    public static String getTemplateName(int type){
        for(QuestionTypeEnum typeEnum : QuestionTypeEnum.values()){
            if(typeEnum.getType()==type){
                return typeEnum.getTemplateName();
            }
        }
        return null;
    }

    public static QuestionTypeEnum getQuestionTypeEnum(int type){
        for(QuestionTypeEnum typeEnum : QuestionTypeEnum.values()){
            if(typeEnum.getType()==type){
                return typeEnum;
            }
        }
        return null;
    }

    public void setTemplateName(String templateName){
        this.templateName = templateName;
    }

    public String getTemplateName(){
        return templateName;
    }
    public void setType(int type){
        this.type = type;
    }
    public int getType(){
        return type;
    }
}
